package cn.jsj.hzu.qm.facecloud.pyAi;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 配置文件读取类
 * <br>
 * 读取配置文件，并将其放在其中的公共静态属性内
 * <br>
 * 这些属性是只读的，必须通过get***方法访问。
 * */
public class FilePropreties {
	private static String PythonPathString;
	private static String RunablePyFileNameString;
	private static int poolSize;
	private static long OutRecordTimeOut;
	private static String basicWorkPath;
	
	static {
		Properties properties = new Properties();
		try {
			//FileInputStream fileInputStream = new FileInputStream(FilePropreties.class.getResource("/LACServer.properties").getPath());
			InputStream  inputStream = FilePropreties.class.getResourceAsStream("/LACJServer.properties");
			properties.load(inputStream);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		PythonPathString = properties.getProperty("PythonPathString");
		RunablePyFileNameString = properties.getProperty("RunablePyFileNameString");
		if (RunablePyFileNameString.equals("auto")) {
			RunablePyFileNameString = FilePropreties.class.getResource("/LAC_SERVER.py").getPath();//+ File.separator + "LAC_SERVER.py";
			RunablePyFileNameString= RunablePyFileNameString.substring(1, RunablePyFileNameString.length());
		}
		poolSize = Integer.parseInt(properties.getProperty("PoolSize"));
		OutRecordTimeOut = Long.parseLong(properties.getProperty("OutRecordTimeOut"));
		basicWorkPath = properties.getProperty("basicWorkPath");
		
	}
	
	
	public static String getPythonPathString() {
		return PythonPathString;
	}
	
	public static String getRunablePyFileNameString() {
		return RunablePyFileNameString;
	}
	public static int getPoolSize() {
		return poolSize;
	}
	
	public static long getOutRecordTimeOut() {
		return OutRecordTimeOut;
	}
	
	public static String getBasicWorkPath() {
		return basicWorkPath;
	}

}
